package com.winchain.chainbill.bill.biz.discount.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.shell.framework.utils.CommonDataUtil;
import com.shell.framework.utils.MessageSender;
import com.shell.framework.utils.SysDateUtil;
import com.shell.governor.modules.message.keyword.SysDctPaidConfirmKeyword;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import org.springframework.stereotype.Component;

@Component
public class BillDctPaidConfirmMsgSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	public void onApplicationEvent(BillEvent<CbDct> t) {
		Bill<CbDct> record = t.getBill();
		CbDct cbDct = (CbDct) record.getSource();
		String template = "MT01614";
		SysDctPaidConfirmKeyword keyWord = new SysDctPaidConfirmKeyword();
		keyWord.setDctAmt(String.valueOf(cbDct.getDctAmt()));

		String dctDate = SysDateUtil.parseDate(cbDct.getDctDate(), "yyyyMMdd", "yyyy-MM-dd");
		keyWord.setDctDate(dctDate);

		String senderId = CommonDataUtil.getUserId();

		MessageSender.sendMessageByTmpl(senderId, template, keyWord, cbDct.getSellerId());
	}
}
